$(function(){
    //可用transition 实现渐隐渐现效果
    var timer;
    var b = 0;
    function show(a){
        var index = a
        $('.focus-list ul li').each(function(index){
            this.className= '';
            $('.focus-picture ul li').eq(index).removeClass('current');
        })
        $('.focus-list ul li').eq(index).addClass('control');
        $('.focus-picture ul li').eq(index).addClass('current');
    }
    $('.focus-list ul li').each(function(index){
        $(this).click(function(){
            clearInterval(timer);
            show(index);
            $(this).mouseout(function(){
                clearInterval(timer);
                b = index;
                autoPLay();
            })
        })
    })
    $('.nextt').click(function(){
        clearInterval(timer);
        b++;
        if(b == $('.focus-list ul li').length){
            b = 0;
        }
        show(b);
    })
    $('.nextt').mouseout(function(){
        clearInterval(timer);
        autoPLay();
    })
    $('.prevv').click(function(){
        clearInterval(timer);
        if(b == $('.focus-list ul li').length){
            b = $('.focus-list ul li').length;
        }
        b--;
        show(b);
    })
    $('.prevv').mouseout(function(){
        clearInterval(timer);
        autoPLay();
    })
    function autoPLay(){
        // clearInterval(dd);
        timer = setInterval(function(){
            b++;
            if(b == $('.focus-list ul li').length){
                b = 0;
            }
            show(b);
        },2000)
    }
    autoPLay();
})